<template>
  <div class="outer">
    <div class="box">
      <header class="header fix">
        <a href="javascript:;" class="backImg" @click="flightIndex"></a>
        <div class="dateTitle">
          <p class="dateCity">
            {{$store.state.flight.go}}-{{$store.state.flight.back}}
          </p>
          <p class="dateDate"><span
            class="dateDateL">{{$store.state.flight.month}}月{{$store.state.flight.day}}日</span><span>{{$store.state.flight.Sunday}}</span>
          </p>
        </div>
      </header>
      <date-toggle-tab :calendarArr="calendarArr"
                       @selectCalendar="dateShow = true"
                       @changeCalendar="weelSel"></date-toggle-tab>
      <div class="travelPolicy fix">
        <label for="travelPolicy" class="label ">仅显示符合差旅标准的航班</label>
        <input id="travelPolicy" type="checkbox" v-model="$store.state.flight.travelPolicyCheck" @click="travelPolicyClick($event)"/>
      </div>
      <div class="noFlight" v-show="noFlight">{{noFlightInfo}}</div>
    </div>
    <div class="main" :class="noFlight ? 'main-height' : 'no-main-height'">
      <scroll :data="$store.state.flight.flightShowDetail">
      <ul class="content" v-if="noList" @click="outerClick">
        <li class="list" v-for="(item,index) in $store.state.flight.flightShowDetail"
            @click="flightListDetail(item,index)">
          <div class="listSub fix">
            <div class="liL">
              <p class="startDate">{{item.fromTime}}</p>
              <p>{{item.fromInfo}}</p>
            </div>
            <div class="liLine">

            </div>
            <div class="liM">
              <p class="toDate">{{item.toTime}}</p>
              <p>{{item.toInfo}}</p>
            </div>
            <div class="liR">
              <p class="money"><span class="moneyIco">¥</span>{{item.lowestPrice}}</p>
              <p v-if="item.restSeatNum>=9" class="Ticket">有票</p>
              <p v-if="item.restSeatNum<9" class="Ticket">剩{{item.restSeatNum}}张</p>
            </div>
          </div>
          <div class="flightType fix">
            <span class="carrierInfo">{{item.carrierInfo}}&nbsp;&nbsp;|&nbsp;&nbsp;{{item.aircraftInfo}}</span>
            <span v-if="item.withinTwoHoursLowestPrice" class="lowPrice">低价</span>
          </div>
        </li>
      </ul>
      </scroll>
    </div>
    <footer>
      <mt-tabbar v-model="selected1" :fixed="true">
        <mt-tab-item id="排序" @click.native="popupVisible1 = true" size="large">
          <i slot="icon" class="iconfont icon-jiage"></i>
          排序
        </mt-tab-item>
        <mt-tab-item id="舱位" @click.native="popupVisible2 = true" size="large">
          <i slot="icon" class="iconfont icon-zuoyiseat"></i>
          舱位
        </mt-tab-item>
        <mt-tab-item id="综合筛选" @click.native="popupVisible3 = true" size="large">
          <i slot="icon" class="iconfont icon-zongheshaixuan-"></i>
          综合筛选
        </mt-tab-item>
      </mt-tabbar>
    </footer>
    <mt-popup v-model="popupVisible1 " position="bottom">
      <div v-for="(pop,index) in popInfo" class="popItem" :class="{activePop:pop.isSelected}" @click="popActive(index)">
        {{pop.name}}<i class="iconfont icon-duihao r" v-show="pop.popShowCheck"></i>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible2 " position="bottom">
      <div v-for="(pop,index) in popInfo1" class="popItem" :class="{activePop:pop.isSelected}"
           @click="popActive1(index)">
        {{pop.name}}<i class="iconfont icon-duihao r" v-show="pop.popShowCheck"></i>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible3" position="bottom">
      <div class="filterBox fix">
        <div class="showSel">
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[0].tabInfos" v-show="tabInfo.a"
             @click="buxian(0,index)">
            <span class="showSelItem1">起飞</span><span class="showSelItem2 ell">{{tabInfo.listName}}</span><span
            class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[1].tabInfos" v-show="tabInfo.a"
             @click="buxian(1,index)">
            <span class="showSelItem1">出发</span><span class="showSelItem2 ell">{{tabInfo.fromAirport}}</span><span
            class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[2].tabInfos" v-show="tabInfo.a"
             @click="buxian(2,index)">
            <span class="showSelItem1">到达</span><span class="showSelItem2 ell">{{tabInfo.toAirport}}</span><span
            class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[3].tabInfos" v-show="tabInfo.a"
             @click="buxian(3,index)">
            <span class="showSelItem1">机型</span><span class="showSelItem2 ell">{{tabInfo.aircrefTypeName}}</span><span
            class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[4].tabInfos" v-show="tabInfo.a"
             @click="buxian(4,index)">
            <span class="showSelItem1">航司</span><span class="showSelItem2 ell">{{tabInfo.carrierName}}</span><span
            class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
        </div>
        <div class="empty" @click="emptySel">
          清空筛选
        </div>
      </div>
      <div class="tabBox fix">
        <div class="tab">
          <div class="tabItem" :class="{activeTabItem:tab.istab}" v-for="(tab,index) in tabs" @click="tabSel(index)">
            {{tab.name}}
          </div>
        </div>
        <div class="tabInfo">
          <!--起飞时间-->
          <div class="tabInfoItem" v-show="a">
            <label v-for="(tabInfo,index) in tabInfo[0].tabInfos" @click="buxian(0,index)">
              <span class="tabInfoSubL">{{tabInfo.listName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--出发机场-->
          <div class="tabInfoItem" v-show="b">
            <label v-for="(tabInfo,index) in tabInfo[1].tabInfos" @click="buxian(1,index)">
              <span class="tabInfoSubL">{{tabInfo.fromAirport}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--到达机场-->
          <div class="tabInfoItem" v-show="c">
            <label v-for="(tabInfo,index) in tabInfo[2].tabInfos" @click="buxian(2,index)">
              <span class="tabInfoSubL">{{tabInfo.toAirport}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--机型-->
          <div class="tabInfoItem" v-show="d">
            <label v-for="(tabInfo,index) in tabInfo[3].tabInfos" @click="buxian(3,index)">
              <span class="tabInfoSubL">{{tabInfo.aircrefTypeName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--航空公司-->
          <div class="tabInfoItem" v-show="e">
            <label v-for="(tabInfo,index) in tabInfo[4].tabInfos" @click="buxian(4,index)">
              <span class="tabInfoSubL">{{tabInfo.carrierName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
        </div>
      </div>
      <div class="queren" @click="queren">
        确认
      </div>
    </mt-popup>
    <date @dateClick="dateClick" @dateBack="dateBack" v-show="dateShow" :max="max" :openTime="openTime" backCustom="1"></date>
    <toast :toastInfo="toastInfo"></toast>
  </div>
</template>

<script>
  import { Navbar, TabItem, Tabbar, Indicator } from 'mint-ui'
  import date from 'components/date.vue'
  import toast from 'components/toast.vue'
  import searchHistory from '../search-history'
  import dateToggleTab from 'components/flight/date-toggle-tab.vue'
  import Scroll from "../../../common/scroll/scroll.vue"

  export default {
    data () {
      return {
        calendarActive: 'is-selected',
        dateShow: false,
        a: true,
        b: false,
        c: false,
        d: false,
        e: false,
        selected1: '排序',//底部tab切换默认高亮
        popupVisible1: false,//底部上升  排序
        popupVisible2: false,//底部上升  舱位
        popupVisible3: false,//底部上升  综合筛选
        isActive: false,
        flightListForm: [],
        noList: true,
        updateTime: 0,
        IntervalTime: '',
        toastInfo: '',
      }
    },
    components: {Navbar, TabItem, Tabbar, date, toast, dateToggleTab,Scroll},
    beforeRouteLeave (to, from, next) {
      clearInterval(this.IntervalTime)
      next()
    },
    methods: {
      outerClick () {
        if (this.updateTime >= 480) {
          this.toastInfo = '操作超时,正在为您跟新航班列表'
          this.flightAjax()
        }
      },
      update () {
        var that = this
        that.updateTime = 0
        that.toastInfo = ''

        this.IntervalTime = setInterval(function () {
          if (that.updateTime >= 480) {
            console.log('操作超时,正在为您跟新航班列表')
            clearInterval(that.IntervalTime)
          } else {
            that.updateTime++
          }
        }, 1000)
      },
      dateBack (type) {
        this.dateShow = false
      },
      dateClick (msg) {
        this.dateShow = false
        this.date = msg
        this.$store.state.flight.openTime = msg

        this.$store.state.flight.fromDate = msg
        this.$store.state.flight.month = msg.substring(5, 7)
        this.$store.state.flight.day = msg.substring(8, 10)
        this.$store.state.flight.Sunday = msg.weekGet()
        this.flightAjax({date: 1})

      },
      travelPolicyClick (e) {
        this.$store.state.flight.travelPolicyCheck = e.target.checked
        this.flightAjax()
      },
      buxian (k, index) {
        //控制样式
        var arr = this.$store.state.flight.tabInfo[k].tabInfos
        var errorNum = arr.length
        if (index == 0) {
          for (var i = 1; i < arr.length; i++) {
            arr[i].a = false
          }
          arr[0].a = true
        } else {
          arr[index].a = !arr[index].a
          for (var k = 0; k < arr.length; k++) {
            if (arr[k].a == false) {
              errorNum--
              if (errorNum == 0) {
                arr[0].a = true
              }
            } else {
              arr[0].a = false
            }
          }

        }

      },
      //综合筛选单个点击
      queren () {
        var flight = this.$store.state.flight
        flight.fromTimes = ''
        flight.fromAirportNames = ''
        flight.toAirportNames = ''
        flight.aircrafts = ''
        flight.carrierNameShorts = ''

        var arr0 = this.tabInfo[0].tabInfos  // 起飞时间
        if (arr0[0].a == true) {
          flight.fromTimes = ''
        } else {
          for (var i = 0; i < arr0.length; i++) {
            if (arr0[i].a == true) {
              flight.fromTimes += arr0[i].listName + ','
            }
          }
        }
        flight.fromTimes = this.fromTimes.substring(0, this.fromTimes.length - 1)

        var arr1 = this.tabInfo[1].tabInfos  //出发机场1
        if (arr1[0].a == true) {
          flight.fromAirportNames = ''
        } else {
          for (var i = 0; i < arr1.length; i++) {
            if (arr1[i].a == true) {
              flight.fromAirportNames += arr1[i].fromAirport + ','
            }
          }
        }
        flight.fromAirportNames = this.fromAirportNames.substring(0, this.fromAirportNames.length - 1)

        var arr2 = this.tabInfo[2].tabInfos  //到达机场2
        if (arr2[0].a == true) {
          flight.toAirportNames = ''
        } else {
          for (var i = 0; i < arr2.length; i++) {
            if (arr2[i].a == true) {
              flight.toAirportNames += arr2[i].toAirport + ','
            }
          }
        }
        flight.toAirportNames = this.toAirportNames.substring(0, this.toAirportNames.length - 1)

        var arr3 = this.tabInfo[3].tabInfos //机型3
        if (arr3[0].a == true) {
          flight.aircrafts = ''
        } else {
          for (var i = 0; i < arr3.length; i++) {
            if (arr3[i].a == true) {
              flight.aircrafts += arr3[i].aircrefType + ','
            }
          }
        }
        flight.aircrafts = this.aircrafts.substring(0, this.aircrafts.length - 1)

        var arr4 = this.tabInfo[4].tabInfos //航空公司4
        if (arr4[0].a == true) {
          flight.carrierNameShorts = ''
        } else {
          for (var i = 0; i < arr4.length; i++) {
            if (arr4[i].a == true) {
              flight.carrierNameShorts += arr4[i].carrierName + ','
            }
          }
        }
        flight.carrierNameShorts = this.carrierNameShorts.substring(0, this.carrierNameShorts.length - 1)

        this.popupVisible3 = false
        this.flightAjax()
      },
      //综合筛选点击
      emptySel () {
        for (var i = 0; i < this.tabInfo.length; i++) {
          for (var j = 1; j < this.tabInfo[i].tabInfos.length; j++) {
            this.$store.state.flight.tabInfo[i].tabInfos[j].a = false
          }
          this.$store.state.flight.tabInfo[i].tabInfos[0].a = true
        }
        var flight = this.$store.state.flight
        flight.fromTimes = ''
        flight.fromAirportNames = ''
        flight.toAirportNames = ''
        flight.aircrafts = ''
        flight.carrierNameShorts = ''
      },
      goRouter () {
        var navItem = this.selected.charAt(this.selected.length - 1)
        switch (navItem) {}
        this.$store.state.flight.fromDate = this.$store.state.flight.week[navItem].fromDate

        this.$store.state.flight.selected = navItem

        this.$store.state.flight.Sunday = this.$store.state.flight.week[navItem].week
        this.flightAjax()
      },
      //重新选择了日历插件重新请求数据
      weelSel (index) {
        this.$store.state.flight.fromDate = this.$store.state.flight.week[index].fromDate
        this.$store.state.flight.openTime = this.$store.state.flight.week[index].fromDate
        this.$store.state.flight.Sunday = '周' + this.$store.state.flight.week[index].week
        this.$store.state.flight.month = this.$store.state.flight.fromDate.substring(5, 7)
        this.$store.state.flight.day = this.$store.state.flight.fromDate.substring(8, 10)

        this.flightAjax({date: 2})

        for (var i = 0; i < this.$store.state.flight.week.length; i++) {
          this.$store.state.flight.week[i].flag = false
        }
        this.$store.state.flight.week[index].flag = true
      },
      flightIndex () {
        this.$router.go(-1)
      },
      flightListDetail (item, index) {
        this.$store.state.flight.index = index
        this.$store.state.flight.currentList = item
        this.$router.push({
          path: '/flight/flightListDetail',
          query: {
            carrierCode: item.carrier.code,
            fromAirport: item.fromAirport,
            toAirport: item.toAirport
          }
        })
      },
      popActive (index) {
        for (var i = 0; i < this.popInfo.length; i++) {
          this.$store.state.flight.popInfo[i].isSelected = false
          this.$store.state.flight.popInfo[i].popShowCheck = false
        }
        this.$store.state.flight.popInfo[index].isSelected = true
        this.$store.state.flight.popInfo[index].popShowCheck = true
        this.popupVisible1 = false

        if (index == 0) {
          this.$store.state.flight.sort = 'price_down'
          this.flightAjax();
        }
        if (index == 1) {
          this.$store.state.flight.sort = 'date_early'
          this.flightAjax();
        }

      },
      //排序事件
      popActive1 (index) {
        for (var i = 0; i < this.popInfo1.length; i++) {
          this.$store.state.flight.popInfo1[i].isSelected = false
          this.$store.state.flight.popInfo1[i].popShowCheck = false
        }
        this.$store.state.flight.popInfo1[index].isSelected = true
        this.$store.state.flight.popInfo1[index].popShowCheck = true
        this.popupVisible2 = false

        switch (index) {
          case 0: // 头等舱/公务舱
            this.$store.state.flight.code = 'C,F'
            this.flightAjax()
            console.log('头等舱/公务舱请求')
            break
          case 1:// 经济舱
            this.$store.state.flight.code = 'Y'
            this.flightAjax()
            console.log('经济舱请求')
            break
          case 2: // 不限
            this.$store.state.flight.code = ''
            this.flightAjax()
            break
        }
      },
      //舱位点击
      tabSel (index) {
        for (var i = 0; i < this.tabs.length; i++) {
          this.tabs[i].istab = false
        }
        this.tabs[index].istab = true
        switch (index) {
          case 0:
            this.a = true
            this.b = false
            this.c = false
            this.d = false
            this.e = false
            break
          case 1:
            this.a = false
            this.b = true
            this.c = false
            this.d = false
            this.e = false
            break
          case 2:
            this.a = false
            this.b = false
            this.c = true
            this.d = false
            this.e = false
            break
          case 3:
            this.a = false
            this.b = false
            this.c = false
            this.d = true
            this.e = false
            break
          case 4:
            this.a = false
            this.b = false
            this.c = false
            this.d = false
            this.e = true
            break
        }
      },
      shuju () {
        var state = this.$store.state
        //请求成功之前就有值,请求成功之后再对比.  还存在则显示.
        var fromTime = state.flight.fromTimes.split(',')
        var fromAirportNames = state.flight.fromAirportNames.split(',')
        var toAirportNames = state.flight.toAirportNames.split(',')
        var aircrafts = state.flight.aircrafts.split(',')
        var carrierNameShorts = state.flight.carrierNameShorts.split(',')

        //综合筛选初始化
        state.flight.tabInfo = [
          {
            tabInfos: [
              {
                listName: '不限',
                a: true
              },
              {
                listName: '00:00-06:00',
                a: false
              },
              {
                listName: '06:00-12:00',
                a: false
              },
              {
                listName: '12:00-18:00',
                a: false
              },
              {
                listName: '18:00-24:00',
                a: false
              },

            ]
          },//起飞时间
          {
            tabInfos: [
              {
                fromAirport: '不限',
                a: true
              },
            ]
          },//出发机场
          {
            tabInfos: [
              {
                toAirport: '不限',
                a: true
              },
            ]
          },//到达机场
          {
            tabInfos: [
              {
                aircrefTypeName: '不限',
                aircrefType: '',
                a: true
              },
            ]
          },//机型
          {
            tabInfos: [
              {
                carrierName: '不限',
                a: true
              },
            ]
          }//航空公司
        ]
        //综合筛选数据重组
        for (var i = 0; i < state.flight.tabInfo.length; i++) {
          switch (i) {
            case 0://起飞时间
              if (fromTime[0] != '') {
                for (var k = 0; k < fromTime.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (fromTime[k] == state.flight.tabInfo[i].tabInfos[j].listName) {
                      state.flight.tabInfo[i].tabInfos[j].a = true
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false
              }
              break
            case 1: //出发机场
              for (var j = 0; j < state.flight.fromCityForms.length; j++) {
                var obj = {}
                obj.fromAirport = state.flight.fromCityForms[j].fromAirport
                obj.a = state.flight.fromCityForms[j].checked;
                state.flight.tabInfo[i].tabInfos.push(obj)
              }
              if (fromAirportNames[0] != '') {
                for (var k = 0; k < fromAirportNames.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (fromAirportNames[k] == state.flight.tabInfo[i].tabInfos[j].fromAirport) {
                      state.flight.tabInfo[i].tabInfos[j].a = true
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false
              }
              break
            case 2:  //到达机场
              for (var j = 0; j < state.flight.toCityForms.length; j++) {
                var obj = {}
                obj.toAirport = state.flight.toCityForms[j].toAirport
                obj.a = state.flight.toCityForms[j].checked;
                state.flight.tabInfo[i].tabInfos.push(obj)
              }
              if (toAirportNames[0] != '') {
                for (var k = 0; k < toAirportNames.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (toAirportNames[k] == state.flight.tabInfo[i].tabInfos[j].toAirport) {
                      state.flight.tabInfo[i].tabInfos[j].a = true
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false
              }
              break
            case 3:  //机型
              for (var j = 0; j < state.flight.aircraftTypes.length; j++) {
                var obj = {}
                obj.aircrefTypeName = state.flight.aircraftTypes[j].aircrefTypeName
                obj.aircrefType = state.flight.aircraftTypes[j].aircrefType
                obj.a = false
                state.flight.tabInfo[i].tabInfos.push(obj)
              }
              if (aircrafts[0] != '') {
                for (var k = 0; k < aircrafts.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (aircrafts[k] == state.flight.tabInfo[i].tabInfos[j].aircrefType) {
                      state.flight.tabInfo[i].tabInfos[j].a = true
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false
              }
              break
            case 4:  //航空公司
              for (var j = 0; j < state.flight.carrierForms.length; j++) {
                var obj = {}
                obj.carrierName = state.flight.carrierForms[j].carrierName
                obj.a = false
                state.flight.tabInfo[i].tabInfos.push(obj)
              }
              if (carrierNameShorts[0] != '') {
                for (var k = 0; k < carrierNameShorts.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (carrierNameShorts[k] == state.flight.tabInfo[i].tabInfos[j].carrierName) {
                      state.flight.tabInfo[i].tabInfos[j].a = true
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false
              }
              break
          }
        }
      },
      flightAjax (key) {
        var that = this
        var state = this.$store.state
        if (!that.toastInfo) {
          that.$vux.loading.show({
            text: '加载中...'
          })
        }
        // 请求成功之前就有值,请求成功之后再对比.  还存在则显示.
        var fromTime = state.flight.fromTimes.split(',')
        var fromAirportNames = state.flight.fromAirportNames.split(',')
        var toAirportNames = state.flight.toAirportNames.split(',')
        var aircrafts = state.flight.aircrafts.split(',')
        var carrierNameShorts = state.flight.carrierNameShorts.split(',')

        var key = key || ''
        that.$vux.loading.show({
          text: '加载中...'
        })
        that.$flight.getFlightList({
          fromCityCode: state.flight.fromCityCode,//出发城市code
          toCityCode: state.flight.toCityCode,//到达城市code
          fromCityId: state.flight.fromCityId,//出发城市id
          toCityId: state.flight.toCityId,//到达城市id
          fromDate: state.flight.fromDate,//出发时间
          sort: state.flight.sort,//时间和价格排序方式  默认为从早到晚:date_early 价格从低到高price_down
          code: state.flight.code,//F:头等舱   C:公务舱     Y:经济舱
          isFilter:  state.flight.travelPolicyCheck,//差旅政策航班是否勾选
          fromType: state.flight.fromType,  //区分出发具体航班
          toType: state.flight.toType, //区分到达具体航班

          fromTimes: state.flight.fromTimes,//出发时间
          fromAirportNames: state.flight.fromAirportNames,//出发机场
          toAirportNames: state.flight.toAirportNames,//达到机场
          aircrafts: state.flight.aircrafts,//机型
          carrierNameShorts: state.flight.carrierNameShorts,//航空公司
        }, function (res) {
          that.$vux.loading.hide();
          clearInterval(that.IntervalTime)
          that.update()//启动定时器
          if (res.code === '0' || res.code === '2') {//查询返回数据为空 0  查询异常  2
            that.$store.state.flight.noFlight = true
            that.$store.state.flight.noFlightInfo = res.message
            //如果重新选择了日期控件
            if (key.date == 1) {
              //星期列表
              state.flight.week = res.week
              for (var i = 0; i < state.flight.week.length; i++) {
                if (state.flight.week[i].flag == true) {
                  state.flight.Sunday = '周' + state.flight.week[i].week
                }
              }
            }
            that.noList = false
            return
          } else if (res.code === '1' || res.code === '8') { //根据差旅政策过滤后为空 1
            that.$store.state.flight.noFlight = true
            that.$store.state.flight.noFlightInfo = res.message
            that.noList = true
            //详细   所有航班列表
            state.flight.flightShowDetail = res.flightListForm[0].flightShowDetail
            state.flight.flightForm = res.flightListForm[0].flightForm
          } else {
            that.$store.state.flight.noFlight = false
            that.noList = true
            //详细   所有航班列表
            state.flight.flightShowDetail = res.flightListForm[0].flightShowDetail
            state.flight.flightForm = res.flightListForm[0].flightForm
          }

          state.flight.productGroupMap = res.ProductGroupMap; // 列表详情数据标题

          if (key.date == 2 || key.date == 1) { //如果点击了星期 或者点击了日期控件
//           出发机场
            state.flight.fromCityForms = res.fromCityForms
//           到达机场
            state.flight.toCityForms = res.toCityForms
//           机型
            state.flight.aircraftTypes = res.aircraftTypes
//           航空公司
            state.flight.carrierForms = res.carrierForms
//           折扣转换
            state.flight.cabinTypeMap = res.cabinTypeMap
//           舱位转换
            state.flight.cabinGradeMap = res.cabinGradeMap
            //综合筛选初始化
            state.flight.tabInfo = [
              {
                tabInfos: [
                  {
                    listName: '不限',
                    a: true
                  },
                  {
                    listName: '00:00-06:00',
                    a: false
                  },
                  {
                    listName: '06:00-12:00',
                    a: false
                  },
                  {
                    listName: '12:00-18:00',
                    a: false
                  },
                  {
                    listName: '18:00-24:00',
                    a: false
                  },

                ]
              },//起飞时间
              {
                tabInfos: [
                  {
                    fromAirport: '不限',
                    a: true
                  },
                ]
              },//出发机场
              {
                tabInfos: [
                  {
                    toAirport: '不限',
                    a: true
                  },
                ]
              },//到达机场
              {
                tabInfos: [
                  {
                    aircrefTypeName: '不限',
                    aircrefType: '',
                    a: true
                  },
                ]
              },//机型
              {
                tabInfos: [
                  {
                    carrierName: '不限',
                    a: true
                  },
                ]
              }//航空公司
            ]
            //综合筛选数据重组
            for (var i = 0; i < state.flight.tabInfo.length; i++) {
              switch (i) {
                case 0://起飞时间
                  if (fromTime[0] != '') {
                    for (var k = 0; k < fromTime.length; k++) {
                      for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                        if (fromTime[k] == state.flight.tabInfo[i].tabInfos[j].listName) {
                          state.flight.tabInfo[i].tabInfos[j].a = true
                        }
                      }
                    }
                    state.flight.tabInfo[i].tabInfos[0].a = false
                  }
                  break
                case 1: //出发机场
                  for (var j = 0; j < state.flight.fromCityForms.length; j++) {
                    var obj = {}
                    obj.fromAirport = state.flight.fromCityForms[j].fromAirport
                    obj.a = state.flight.fromCityForms[j].checked;
                    state.flight.tabInfo[i].tabInfos.push(obj)
                  }
                  if (fromAirportNames[0] != '') {
                    for (var k = 0; k < fromAirportNames.length; k++) {
                      for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                        if (fromAirportNames[k] == state.flight.tabInfo[i].tabInfos[j].fromAirport) {
                          state.flight.tabInfo[i].tabInfos[j].a = true
                        }
                      }
                    }
                    state.flight.tabInfo[i].tabInfos[0].a = false
                  }
                  break
                case 2:  //到达机场
                  for (var j = 0; j < state.flight.toCityForms.length; j++) {
                    var obj = {}
                    obj.toAirport = state.flight.toCityForms[j].toAirport
                    obj.a = state.flight.toCityForms[j].checked;
                    state.flight.tabInfo[i].tabInfos.push(obj)
                  }
                  if (toAirportNames[0] != '') {
                    for (var k = 0; k < toAirportNames.length; k++) {
                      for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                        if (toAirportNames[k] == state.flight.tabInfo[i].tabInfos[j].toAirport) {
                          state.flight.tabInfo[i].tabInfos[j].a = true
                        }
                      }
                    }
                    state.flight.tabInfo[i].tabInfos[0].a = false
                  }
                  break
                case 3:  //机型
                  for (var j = 0; j < state.flight.aircraftTypes.length; j++) {
                    var obj = {}
                    obj.aircrefTypeName = state.flight.aircraftTypes[j].aircrefTypeName
                    obj.aircrefType = state.flight.aircraftTypes[j].aircrefType
                    obj.a = false
                    state.flight.tabInfo[i].tabInfos.push(obj)
                  }
                  if (aircrafts[0] != '') {
                    for (var k = 0; k < aircrafts.length; k++) {
                      for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                        if (aircrafts[k] == state.flight.tabInfo[i].tabInfos[j].aircrefType) {
                          state.flight.tabInfo[i].tabInfos[j].a = true
                        }
                      }
                    }
                    state.flight.tabInfo[i].tabInfos[0].a = false
                  }
                  break
                case 4:  //航空公司
                  for (var j = 0; j < state.flight.carrierForms.length; j++) {
                    var obj = {}
                    obj.carrierName = state.flight.carrierForms[j].carrierName
                    obj.a = false
                    state.flight.tabInfo[i].tabInfos.push(obj)
                  }
                  if (carrierNameShorts[0] != '') {
                    for (var k = 0; k < carrierNameShorts.length; k++) {
                      for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                        if (carrierNameShorts[k] == state.flight.tabInfo[i].tabInfos[j].carrierName) {
                          state.flight.tabInfo[i].tabInfos[j].a = true
                        }
                      }
                    }
                    state.flight.tabInfo[i].tabInfos[0].a = false
                  }
                  break
              }
            }
          }
          //如果重新选择了日期控件
          if (key.date == 1) {
            that.$vux.loading.hide();
            //星期列表
            state.flight.week = res.week
            for (var i = 0; i < state.flight.week.length; i++) {
              if (state.flight.week[i].flag == true) {
                state.flight.Sunday = '周' + state.flight.week[i].week
              }
            }
          }
          //结束加载动画
        }, function (err) {
          that.$vux.loading.hide();
          $flightTools.errorToIndex(that);
        })

      }
    },
    beforeMount () {
      this.selected = this.$store.state.flight.selected
    },
    mounted () {
      // 综合筛选数据初始化
      for (var i = 0; i < this.tabs.length; i++) {
        this.$store.state.flight.tabs[i].istab = false
      }
      this.$store.state.flight.tabs[0].istab = true
      this.a = true
      this.b = false
      this.c = false
      this.d = false
      this.e = false

      //设置顶部初始selected值.这个值绝对不要放在computed中设置.因为ted它只设置一次.compu每次加载都要从新计算
      this.selected = this.$store.state.flight.selected
      if (this.$route.query.from == 'flightIndex') {
        var flight = this.$store.state.flight
        flight.fromTimes = ''
        flight.fromAirportNames = ''
        flight.toAirportNames = ''
        flight.aircrafts = ''
        flight.carrierNameShorts = ''
        this.$store.state.flight.travelPolicyCheck = true
        this.shuju()
        this.update()
      } else {
        this.flightAjax()
      }
    },
    computed: {
      calendarArr() {
        return this.$store.state.flight.week
      },
      openTime () {
        return this.$store.state.flight.openTime
      },
      max () {
        return '365'.future()
      },
      fromTimes () {
        return this.$store.state.flight.fromTimes
      }, //出发时间参数
      fromAirportNames () {
        return this.$store.state.flight.fromAirportNames
      },//出发机场参数
      toAirportNames () {
        return this.$store.state.flight.toAirportNames
      },//到达机场参数
      aircrafts () {
        return this.$store.state.flight.aircrafts
      },//机型参数
      carrierNameShorts () {
        return this.$store.state.flight.carrierNameShorts
      },//航空公司参数
      flight () {
        return this.$store.state.flight
      },
      popInfo () {
        return this.$store.state.flight.popInfo
      },
      popInfo1 () {
        return this.$store.state.flight.popInfo1
      },
      noFlight () {
        return this.$store.state.flight.noFlight
      },
      noFlightInfo () {
        return this.$store.state.flight.noFlightInfo
      },
      tabs () {
        return this.$store.state.flight.tabs
      },
      tabInfo () {
        return this.$store.state.flight.tabInfo
      }
    }
  }
</script>

<style scoped>
  .noFlight {
    display: flex;
    padding: 0 .5rem;
    text-align: left;
    height: 2rem;
    align-items: center;
    background-color: #efefef;
  }
</style>
<!--自定义头-->
<style scoped>
  .header {
    background: #46a1bb;
    height: 2.2rem;
    background-size: cover;
    color: #fff;
    padding: 0 .75rem;
  }

  .backImg {
    float: left;
    width: 10%;
    height: 2.2rem;
    line-height: 2.2rem;
    text-align: left;
    background: url('../../../assets/images/back.png') no-repeat left center;
    background-size: .6rem 1.1rem;

  }
  .dateTitle {
    float: left;
    width: 80%;
    height: 1.95rem;
    margin-top: .25rem;
    text-align: center;
  }

  .dateCity {
    width: 100%;
    font-size: .8rem;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
  .dateDate {
    margin-top: .15rem;
    font-size: .6rem;
  }
  .dateDateL {
    margin-right: .2rem;
  }
</style>

<!--综合筛选-->
<style scoped>
  /*筛选结果*/
  .empty {
    height: 1rem;
    line-height: 1rem;
    color: #46a1bb;
    font-size: .75rem;
    float: right;
    margin-bottom: .5rem;
    margin-top: .5rem;
    margin-right: 1.5%;
  }
  .filterBox {
    border-top: 1px solid #eee;
    padding: .25rem .45rem 0 .45rem;
  }
  .showSel {
    /*height: 10.5rem;*/
    overflow: auto;
  }
  .showSelItem {
    border: 1px solid #46a1bb; /*no*/
    width: 47%;
    height: 1.4rem;
    line-height: 1.4rem;
    color: #46a1bb;
    font-size: .65rem;
    float: left;
    margin: .25rem 1.5% 0;
    box-sizing: border-box;
  }
  .showSelItem1 {
    float: left;
    margin-left: .25rem;
    margin-right: .25rem;
  }
  .showSelItem2 {
    float: left;
  }
  .showSelItem3 {
    float: right;
    margin-right: .25rem;
  }
  /*筛选条件*/
  .tabBox {
    width: 100%;
    display: flex;
    border-top: 1px solid #eee; /*no*/
  }
  .queren {
    height: 2.5rem;
    width: 100%;
    background-color: #46a1bb;
    text-align: center;
    line-height: 2.5rem;
    color: #fff;
    font-size: .9rem;
  }
  .mint-popup-bottom {
    width: 100%;
  }
  .tab {
    font-size: .75rem;
    flex: 0 0 30%;
  }
  .tabInfo {
    flex: 0 0 70%;
    height: 12.5rem;
    overflow: auto;
  }
  .tabInfoSubL {
    font-size: .75rem;
    margin-left: 1.2rem;
  }
  .tabInfoSubR {
    float: right;
    width: .75rem;
    height: .75rem;
    margin: .75rem 1.5rem;
    border: 1px solid #46a1bb; /*no*/
  }
  .tabInfoSubR1 {
    float: right;
    width: .75rem;
    height: .75rem;
    margin: 0px 1.5rem;
    font-size: .75rem;
    color: #46a1bb;
  }
  .tabItem {
    height: 2.5rem;
    line-height: 2.5rem;
    width: 100%;
    background-color: #fff;
    text-align: center;
    border-bottom: 1px solid #eee; /*no*/
    border-right: 1px solid #eee; /*no*/
  }
  .tab .activeTabItem {
    background-color: #46a1bb;
    border-right: none;
    color: #fff;
  }
  .tabInfoItem {
    height: 2.5rem;
    line-height: 2.5rem;
    width: 100%;

  }
  .tabInfoItem label {
    width: 100%;
    height: 100%;
    display: block;
    margin: auto;
    border-bottom: 1px solid #eee; /*no*/
  }
</style>
<style scoped>
  .popItem {
    line-height: 2.5rem;
    width: 100%;
    border-bottom: 1px solid #eee; /*no*/
    font-size: .75rem;
    box-sizing: border-box;
    padding: 0 1.2rem;
  }
  .activePop {
    color: #46a1bb;
  }
</style>
<style scoped>
  .carrierInfo {
    padding: .25rem 0;
    float: left;
  }
  .lowPrice {
    background-color: #F60;
    color: #fff;
    float: right;
    padding: .25rem;
    border-radius: .2rem;
  }
  .box {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1;
  }
  .flightType {
    margin-top: .25rem;
  }
  .money {
    color: #F60;
    text-align: right;
    font-size: .9rem;
    margin-bottom: .2rem;
  }
  .Ticket {
    text-align: right;
    color: #f60;
  }
  .moneyIco {
    font-size: .65rem;
  }
  .startDate {
    font-size: .9rem;
    margin-bottom: .4rem;
    color: #333;
  }
  .toDate {
    font-size: .9rem;
    margin-bottom: .4rem;
    color: #333;
  }
  .list {
    padding: .75rem 0;
    color: #888;
    border-bottom: 1px solid #eee; /*no*/
  }
  .listSub {
    display: flex;
    text-align: center;
  }
  .listSub>div:nth-child(1) {
    flex: 0 0 32%;
    text-align: left;
  }
  .listSub>div:nth-child(3) {
    flex: 0 0 32%;
  }
  .listSub>div:nth-child(4) {
    flex: 0 0 23%;
  }
  .liM {
    text-align: right;
  }
  .liLine {
    flex: 0 0 13%;
    height: .25rem;
    background: url("../../../assets/images/goBackLine90.png") no-repeat;
    margin: .75rem 0;
    background-size: cover;
  }
  .outer {
    width: 100%;
    position: relative;
    background-color: #fff;
    height: 100%;
    font-size: .6rem;
    -webkit-overflow-scrolling: touch;
    -overflow-scrolling: touch;
    overflow: hidden;
  }
  .outer ::-webkit-scrollbar {
    display: none;
  }
  .main {
    position: relative;
    background-color: #fff;
    overflow: hidden;
  }
  .main-height {
    height: calc(100% - 11.7rem);
    margin-top: 9.2rem;
  }
  .no-main-height {
    height: calc(100% - 9.7rem);
    margin-top: 7.2rem;
  }
  .main div>ul {
    padding: 0 .5rem;
    -webkit-overflow-scrolling: touch;
  }
  .title {
    color: #fff;
    background-color: #0d496b;
    padding: .5rem .25rem;
    display: flex;
  }
  .container {
    display: flex;
  }
  .dateTab {
    flex:  0 0 85%;
  }
  .itemDate {
    flex: 1;
    text-align: center;
    padding: .25rem 0;
    border-radius: .25rem;
    font-size: .6rem;
  }

  .itemDateNum {
    margin-top: .25rem;
  }
  .dateImg {
    color: #3e3a39;
    flex:  0 0 15%;
    text-align: center;
    height: 1.75rem;
    background: url("../../../assets/images/calendar.png") no-repeat center center;
    background-size: 1.05rem 1.15rem;
  }
</style>
<!--底部tab-->
<style scoped>
  .iconfont {
    font-size: .9rem;
  }
  footer {
    height: 2.5rem;
    position: fixed; /*不加固定定位是block加高度的,会把父级撑开.加了之后脱离文档流*/
    right: 0;
    bottom: 0;
    left: 0;
  }
  footer .mint-tabbar {
    height: 2.5rem;
    font-weight: bold;
  }
  footer .mint-tab-item {
    padding: .375rem 0;
  }
  footer .mint-tab-item-label {
    font-size: .55rem;
    margin-top: .25rem;
  }
  footer .mint-tabbar > .mint-tab-item.is-selected {
    color: #46a1bb;
  }
  footer .mint-tab-item-icon {
    margin:  0 auto!important;
  }
  .mint-navbar .mint-tab-item {
    padding: .25rem 0;
    font-size: .6rem;
  }
  .mint-navbar .mint-tab-item p {
    font-size: .6rem;
  }
  .is-selected {
    border: none;
    background-color: #46a1bb;
    color: #fff;
    margin-bottom: 0;
  }
  .mint-navbar {
    background-color: #0d496b;
  }
</style>
<!--仅显示符合差旅标准的航班-->
<style scoped>
  .travelPolicy {
    box-sizing: border-box;
    padding: 0 .5rem;
    border-bottom: 1px solid #ccc;
    line-height: 2rem;
    height: 2rem;
    box-sizing: border-box;
    font-size: .75rem;
    display: flex;
    background-color: #fff;
  }
  .travelPolicy input[type=checkbox] {
    /*flex: 10%;*/
    height: .8rem;
    margin-top: .55rem;
    flex:  0 0 10%;
  }
  .travelPolicy.fix {
    width: 100%;
  }
  .label {
    flex: 0 0 90%;
    font-size: .7rem;
    color: #666;
  }
</style>
